package org.csu.demo.db.service;

import org.csu.demo.db.domain.Students;
import org.csu.demo.db.persistence.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService{
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public List<Students> getAllStudents() {
        return studentMapper.selectList(null);
    }

    @Override
    public Students getStudentById(String id) {
        return studentMapper.selectById(id);
    }

    @Override
    public void addStudent(Students student) {
        studentMapper.insert(student);
    }

    @Override
    public void updateStudent(Students student) {
        studentMapper.updateById(student);
    }

    @Override
    public void deleteStudent(String id) {
        studentMapper.deleteById(id);
    }
}
